= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 A u t h o r :   Y o u n g w o o k   K i m   ( K o r e a n ) 
 
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 
 
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 C o n t a c t :   r u m i a 0 6 0 1 @ g m a i l . c o m 
 
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 
 
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
   T  %     
 
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 
 
 K E Y D O W N    ̹,   Dĳ  t  t  D\  G U I    D̲    tǔ  t ǔ  G U I    %@    $  %( հ) XՔ  p̹  0  L8t.   G U I X  %tǀ  \  XX  ȹƤ  tǤ|  ̬XՔ  t.   H P |   ¤p  ¤Д    2 |  ̹ܴ  @  ŨL? 
 
 
 
 . .   i m a g e : :   A d v a n c e d I n p u t O u t p u t 1 . g i f 
 
       : c l a s s :   i n l i n e d - r i g h t 
 
 
 
 . .   c o d e - b l o c k : :   p y t h o n 
 
       : l i n e n o s : 
 
 
 
       i m p o r t   s y s ,   p y g a m e 
 
       p y g a m e . i n i t ( ) 
 
 
 
       s i z e   =   w i d t h ,   h e i g h t   =   3 2 0 ,   2 4 0 
 
       s p e e d   =   [ 2 ,   2 ] 
 
       b l a c k   =   0 ,   0 ,   0 
 
 
 
       s c r e e n   =   p y g a m e . d i s p l a y . s e t _ m o d e ( s i z e ) 
 
 
 
       b a l l   =   p y g a m e . i m a g e . l o a d ( " A d v a n c e d I n p u t O u t p u t 1 . g i f " ) 
 
       b a l l r e c t   =   b a l l . g e t _ r e c t ( ) 
 
 
 
       w h i l e   1 : 
 
               f o r   e v e n t   i n   p y g a m e . e v e n t . g e t ( ) : 
 
                       i f   e v e n t . t y p e   = =   p y g a m e . Q U I T :   s y s . e x i t ( ) 
 
 
 
               b a l l r e c t   =   b a l l r e c t . m o v e ( s p e e d ) 
 
               i f   b a l l r e c t . l e f t   <   0   o r   b a l l r e c t . r i g h t   >   w i d t h : 
 
                       s p e e d [ 0 ]   =   - s p e e d [ 0 ] 
 
               i f   b a l l r e c t . t o p   <   0   o r   b a l l r e c t . b o t t o m   >   h e i g h t : 
 
                       s p e e d [ 1 ]   =   - s p e e d [ 1 ] 
 
 
 
               s c r e e n . f i l l ( b l a c k ) 
 
               s c r e e n . b l i t ( b a l l ,   b a l l r e c t ) 
 
               p y g a m e . d i s p l a y . f l i p ( ) 
 
 
 
 . .   i m a g e : :   A d v a n c e d I n p u t O u t p u t 2 . g i f 
 
       : c l a s s :   i n l i n e d - r i g h t 
 
 
 
 . .   c o d e - b l o c k : :   p y t h o n 
 
       : l i n e n o s : 
 
 
 
       i m p o r t   s y s ,   p y g a m e 
 
       p y g a m e . i n i t ( ) 
 
 
 
       s i z e   =   w i d t h ,   h e i g h t   =   3 2 0 ,   2 4 0 
 
       s p e e d   =   [ 2 ,   2 ] 
 
       b l a c k   =   0 ,   0 ,   0 
 
 
 
       s c r e e n   =   p y g a m e . d i s p l a y . s e t _ m o d e ( s i z e ) 
 
 
 
       b a l l   =   p y g a m e . i m a g e . l o a d ( " A d v a n c e d I n p u t O u t p u t 2 . g i f " ) 
 
       b a l l r e c t   =   b a l l . g e t _ r e c t ( ) 
 
 
 
       w h i l e   1 : 
 
               f o r   e v e n t   i n   p y g a m e . e v e n t . g e t ( ) : 
 
                       i f   e v e n t . t y p e   = =   p y g a m e . Q U I T :   s y s . e x i t ( ) 
 
 
 
               b a l l r e c t   =   b a l l r e c t . m o v e ( s p e e d ) 
 
               i f   b a l l r e c t . l e f t   <   0   o r   b a l l r e c t . r i g h t   >   w i d t h : 
 
                       s p e e d [ 0 ]   =   - s p e e d [ 0 ] 
 
               i f   b a l l r e c t . t o p   <   0   o r   b a l l r e c t . b o t t o m   >   h e i g h t : 
 
                       s p e e d [ 1 ]   =   - s p e e d [ 1 ] 
 
 
 
               s c r e e n . f i l l ( b l a c k ) 
 
               s c r e e n . b l i t ( b a l l ,   b a l l r e c t ) 
 
               p y g a m e . d i s p l a y . f l i p ( ) 
 
 
 
   2 |  ̹ܴ  @  }.   D  t,   T   t\     ȩ  LD  L    .   Ż  \  x?   tX  DtŘ  X.   ,   p  ȬD  .   X,   @    Pخ̹  ǔ  @  ȬD  .   X̹  t  @  D  %t.   t  D  \  tЭ     D  ̹䴴|  \. 
 
 
 
 . .   i m a g e : :   A d v a n c e d I n p u t O u t p u t 3 . g i f 
 
       : c l a s s :   i n l i n e d - r i g h t 
 
 
 
 . .   c o d e - b l o c k : :   p y t h o n 
 
       : l i n e n o s : 
 
 
 
       i m p o r t   s y s ,   p y g a m e 
 
       p y g a m e . i n i t ( ) 
 
 
 
       s i z e   =   w i d t h ,   h e i g h t   =   3 2 0 ,   2 4 0 
 
       s p e e d   =   [ 2 ,   2 ] 
 
       b l a c k   =   0 ,   0 ,   0 
 
 
 
       s c r e e n   =   p y g a m e . d i s p l a y . s e t _ m o d e ( s i z e ) 
 
 
 
       b a l l   =   p y g a m e . i m a g e . l o a d ( " A d v a n c e d I n p u t O u t p u t 3 . g i f " ) 
 
       b a l l r e c t   =   b a l l . g e t _ r e c t ( ) 
 
 
 
       w h i l e   1 : 
 
               f o r   e v e n t   i n   p y g a m e . e v e n t . g e t ( ) : 
 
                       i f   e v e n t . t y p e   = =   p y g a m e . Q U I T :   s y s . e x i t ( ) 
 
 
 
               b a l l r e c t   =   b a l l r e c t . m o v e ( s p e e d ) 
 
               i f   b a l l r e c t . l e f t   <   0   o r   b a l l r e c t . r i g h t   >   w i d t h : 
 
                       s p e e d [ 0 ]   =   - s p e e d [ 0 ] 
 
               i f   b a l l r e c t . t o p   <   0   o r   b a l l r e c t . b o t t o m   >   h e i g h t : 
 
                       s p e e d [ 1 ]   =   - s p e e d [ 1 ] 
 
 
 
               s c r e e n . f i l l ( b l a c k ) 
 
               s c r e e n . b l i t ( b a l l ,   b a l l r e c t ) 
 
               p y g a m e . d i s p l a y . f l i p ( ) 
 
 
 
 . .   i m a g e : :   A d v a n c e d I n p u t O u t p u t 4 . g i f 
 
       : c l a s s :   i n l i n e d - r i g h t 
 
 
 
 . .   c o d e - b l o c k : :   p y t h o n 
 
       : l i n e n o s : 
 
 
 
       i m p o r t   s y s ,   p y g a m e 
 
       p y g a m e . i n i t ( ) 
 
 
 
       s i z e   =   w i d t h ,   h e i g h t   =   3 2 0 ,   2 4 0 
 
       s p e e d   =   [ 2 ,   2 ] 
 
       b l a c k   =   0 ,   0 ,   0 
 
 
 
       s c r e e n   =   p y g a m e . d i s p l a y . s e t _ m o d e ( s i z e ) 
 
 
 
       b a l l   =   p y g a m e . i m a g e . l o a d ( " A d v a n c e d I n p u t O u t p u t 4 . g i f " ) 
 
       b a l l r e c t   =   b a l l . g e t _ r e c t ( ) 
 
 
 
       w h i l e   1 : 
 
               f o r   e v e n t   i n   p y g a m e . e v e n t . g e t ( ) : 
 
                       i f   e v e n t . t y p e   = =   p y g a m e . Q U I T :   s y s . e x i t ( ) 
 
 
 
               b a l l r e c t   =   b a l l r e c t . m o v e ( s p e e d ) 
 
               i f   b a l l r e c t . l e f t   <   0   o r   b a l l r e c t . r i g h t   >   w i d t h : 
 
                       s p e e d [ 0 ]   =   - s p e e d [ 0 ] 
 
               i f   b a l l r e c t . t o p   <   0   o r   b a l l r e c t . b o t t o m   >   h e i g h t : 
 
                       s p e e d [ 1 ]   =   - s p e e d [ 1 ] 
 
 
 
               s c r e e n . f i l l ( b l a c k ) 
 
               s c r e e n . b l i t ( b a l l ,   b a l l r e c t ) 
 
               p y g a m e . d i s p l a y . f l i p ( ) 
 
 
 
 . .   i m a g e : :   A d v a n c e d I n p u t O u t p u t 5 . g i f 
 
       : c l a s s :   i n l i n e d - r i g h t 
 
 
 
 . .   c o d e - b l o c k : :   p y t h o n 
 
       : l i n e n o s : 
 
 
 
       i m p o r t   s y s ,   p y g a m e 
 
       p y g a m e . i n i t ( ) 
 
 
 
       s i z e   =   w i d t h ,   h e i g h t   =   3 2 0 ,   2 4 0 
 
       s p e e d   =   [ 2 ,   2 ] 
 
       b l a c k   =   0 ,   0 ,   0 
 
 
 
       s c r e e n   =   p y g a m e . d i s p l a y . s e t _ m o d e ( s i z e ) 
 
 
 
       b a l l   =   p y g a m e . i m a g e . l o a d ( " A d v a n c e d I n p u t O u t p u t 5 . g i f " ) 
 
       b a l l r e c t   =   b a l l . g e t _ r e c t ( ) 
 
 
 
       w h i l e   1 : 
 
               f o r   e v e n t   i n   p y g a m e . e v e n t . g e t ( ) : 
 
                       i f   e v e n t . t y p e   = =   p y g a m e . Q U I T :   s y s . e x i t ( ) 
 
 
 
               b a l l r e c t   =   b a l l r e c t . m o v e ( s p e e d ) 
 
               i f   b a l l r e c t . l e f t   <   0   o r   b a l l r e c t . r i g h t   >   w i d t h : 
 
                       s p e e d [ 0 ]   =   - s p e e d [ 0 ] 
 
               i f   b a l l r e c t . t o p   <   0   o r   b a l l r e c t . b o t t o m   >   h e i g h t : 
 
                       s p e e d [ 1 ]   =   - s p e e d [ 1 ] 
 
 
 
               s c r e e n . f i l l ( b l a c k ) 
 
               s c r e e n . b l i t ( b a l l ,   b a l l r e c t ) 
 
               p y g a m e . d i s p l a y . f l i p ( ) 
 
 
 
 t  E v e n t 8  M O U S E B U T T O N U P t   .   ȹƤ U P     @  ܴ D O W N     ٳ|\  X|   .   ̹}  M O U S E B U T T O N U P t  \1Tt,   e v e n t . p o s   x   y D  0]t|  XՔp,   t  @  tЭ  D  и.   \,   tЭt    Ȭ    |ǴŬ  D̲  ɔ  c o l l i d e p o i n t |  UxXt  .   ̹}   t,    Ɛ       |  tЭ |  XXՌ  .     L,   |  ptǸXՔ  \  ̬̹t  DՔXՌ  . 
 
 %D  \  P     tȬX,   ( E v e n t 8  L) 
 
 ( 2 7 0 ,   4 2 5 ,   4 5 ,   4 5 ) @  ( 3 2 5 ,   4 2 5 ,   4 5 ,   4 5 ) . 
 
 %D  \  P  ĳ  tȬhD  UxX|.   ( d r a w B u t t o n s   L) 
 
 ( m a r g i n ,   h e i g h t   -   r   - 1 0   ,   r ,   r )   ( m a r g i n   +   r   +   r _ m a r g i n ,   h e i g h t   -   r   -   1 0 ,   r ,   r ) . 
 
 X  ,   %    %  t  ٳ|t|  \.     Jt,   X       0   !   ( %  ) D  lx  ĬD  t  ( %  )   D  LDŴ0  t,   t  D  ٳ|\  \  P  t  @  |  t.   P  D  X՘\  6D    ǔ  h  <\,   t  @  m  ½  h|  \. 
 
 
 
 < 8  Tܴ>   : : 
 
 
 
         i m p o r t   p y g a m e ,   s y s 
 
         f r o m   p y g a m e . l o c a l s   i m p o r t * 
 
         
 
         m a x H P   =   1 0   
 
         w h i t e   =   ( 2 5 5 , 2 5 5 , 2 5 5 ) 
 
         g r a y   =   ( 1 2 7 , 1 2 7 , 1 2 7 ) 
 
         b l a c k   =   ( 0 , 0 , 0 ) 
 
         r e d   =   ( 2 5 5 , 0 , 0 ) 
 
         g r e e n   =   ( 0 , 2 5 5 , 0 ) 
 
         b l u e   =   ( 0 , 0 , 2 5 5 ) 
 
         p y g a m e . i n i t ( ) 
 
         p y g a m e . d i s p l a y . s e t _ c a p t i o n ( " A r r a y   b u t t o n s   P r o j e c t " ) 
 
         w i d t h   =   6 4 0   
 
         h e i g h t   =   4 8 0 
 
         m y S c r e e n   =   p y g a m e . d i s p l a y . s e t _ m o d e ( ( w i d t h ,   h e i g h t ) ) 
 
         m y T e x t F o n t   =   p y g a m e . f o n t . F o n t ( " H o o n W h i t e c a t R . t t f " ,   3 2 ) 
 
         m y T e x t   =   m y T e x t F o n t . r e n d e r ( ( s t r ( m a x H P )   +   " / "   +   s t r ( m a x H P ) ) ,   T r u e ,   r e d ,   g r a y ) 
 
         m y T e x t A r e a   =   m y T e x t . g e t _ r e c t ( ) 
 
         m y T e x t A r e a . c e n t e r   =   ( w i d t h / 2 ,   h e i g h t / 2 ) 
 
         f p s C l o c k   =   p y g a m e . t i m e . C l o c k ( ) 
 
         
 
         d e f   m a i n ( ) : 
 
                 H P   =   5 
 
                 
 
                 w h i l e   T r u e : 
 
                         m y T e x t   =   m y T e x t F o n t . r e n d e r ( ( s t r ( H P )   +   " / "   +   s t r ( m a x H P ) ) ,   T r u e ,   r e d ,   g r a y ) 
 
                 
 
                         m y S c r e e n . f i l l ( g r a y ) 
 
         
 
                         m y S c r e e n . b l i t ( m y T e x t ,   m y T e x t A r e a ) 
 
                         d r a w H P ( H P ) 
 
                         d r a w B u t t o n s ( ) 
 
         
 
                         f o r   e v e n t   i n   p y g a m e . e v e n t . g e t ( ) : 
 
                                 i f   e v e n t . t y p e   = =   Q U I T : 
 
                                         p y g a m e . q u i t ( ) 
 
                                         s y s . e x i t ( ) 
 
                                 e l i f   e v e n t . t y p e   = =   K E Y D O W N : 
 
                                         i f   e v e n t . k e y   = =   K _ U P : 
 
                                                 i f   H P   ! =   1 0 : 
 
                                                         H P   =   H P   +   1 
 
                                         e l i f   e v e n t . k e y   = =   K _ D O W N : 
 
                                                 i f   H P   ! =   0 : 
 
                                                         H P   =   H P   -   1 
 
                                 e l i f   e v e n t . t y p e   = =   M O U S E B U T T O N U P :   # 1 
 
                                         x ,   y   =   e v e n t . p o s 
 
                                         i f   p y g a m e . R e c t ( 2 7 0 ,   4 2 5 ,   4 5 ,   4 5 ) . c o l l i d e p o i n t ( x ,   y ) : 
 
                                                 i f   H P   ! =   1 0 : 
 
                                                         H P   =   H P   +   1 
 
                                         e l i f   p y g a m e . R e c t ( 3 2 5 ,   4 2 5 ,   4 5 ,   4 5 ) . c o l l i d e p o i n t ( x ,   y ) : 
 
                                                 i f   H P   ! =   0 : 
 
                                                         H P   =   H P   -   1             
 
                 
 
                         p y g a m e . d i s p l a y . u p d a t e ( ) 
 
                         f p s C l o c k . t i c k ( 6 0 ) 
 
         
 
         d e f   d r a w H P ( H P ) : 
 
                 r   =   i n t ( ( h e i g h t   -   4 0 )   /   m a x H P ) 
 
         
 
                 p y g a m e . d r a w . r e c t ( m y S c r e e n ,   b l a c k ,   ( 2 0 ,   2 0 ,   2 0 ,   2 0   +   ( ( m a x H P   -   0 . 5 )   *   r ) ) ) 
 
         
 
                 f o r   i   i n   r a n g e ( m a x H P ) : 
 
                         i f   H P   > =   ( m a x H P   -   i ) : 
 
                                 p y g a m e . d r a w . r e c t ( m y S c r e e n ,   r e d ,   ( 2 0 ,   2 0   +   ( i   *   r ) ,   2 0 ,   r ) ) 
 
                         p y g a m e . d r a w . r e c t ( m y S c r e e n ,   w h i t e ,   ( 2 0 ,   2 0   +   ( i   *   r ) ,   2 0 ,   r ) ,   1 ) 
 
         
 
                 r e t u r n 
 
         
 
         d e f   d r a w B u t t o n s ( ) : 
 
                 r   =   4 5 
 
                 r _ m a r g i n   =   1 0 
 
                 c o l o r s   =   [ r e d ,   b l a c k ] 
 
                 
 
                 n u m   =   2 
 
                 m a r g i n   =   i n t ( ( w i d t h   -   ( ( r   *   n u m )   +   ( r _ m a r g i n   *   ( n u m   -   1 ) ) ) )   /   2 ) 
 
                 f o r   i   i n   r a n g e ( 0 ,   n u m ) : 
 
                         l e f t   =   m a r g i n   +   ( i   *   r )   +   ( i   *   r _ m a r g i n ) 
 
                         u p   =   h e i g h t   -   r   -   1 0 
 
                         p y g a m e . d r a w . r e c t ( m y S c r e e n ,   c o l o r s [ i ] ,   ( l e f t ,   u p ,   r ,   r ) ) 
 
                         p y g a m e . d r a w . r e c t ( m y S c r e e n ,   g r a y ,   ( l e f t   +   2 ,   u p   +   2 ,   r   -   4 ,   r   -   4 ) ,   2 ) 
 
         
 
         i f   _ _ n a m e _ _   = =   ' _ _ m a i n _ _ ' : 
 
                 m a i n ( ) 
 
         